const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    onLoad() {

        //GPool.init();

        //获取节点并初始化信息
        GPool.get("LabelIten", { setData: { showString: "ok", num: 123 } }).then((node: cc.Node) => {
            console.error("LabelIten", node);
            node.parent = this.node;
            this.scheduleOnce(() => {
                //回收节点
                GPool.put(node);
            }, 3);
        });

        GPool.get("ColorItem", { setData: { showColor: cc.Color.RED, tips: "加载成功" } }).then((node: cc.Node) => {
            console.error("ColorItem", node);
            node.parent = this.node;
            node.position = cc.v2(200, 200);
            this.scheduleOnce(() => {
                //回收节点
                GPool.put(node);
            }, 3);
        });

        this.scheduleOnce(() => {
            GPool.get("ColorItem", { setData: { showColor: cc.Color.YELLOW, tips: "加载成功" } }).then((node: cc.Node) => {
                console.error("ColorItem", node);
                node.parent = this.node;
                node.position = cc.v2(200, 200);
                this.scheduleOnce(() => {
                    //回收节点
                    GPool.put(node);
                }, 3);
            });
        }, 6);



        //仅仅获取节点信息
        // GPool.get("LabelIten", { isGetInfo: true }).then((node: cc.Node) => {
        //     console.error("node info", node);
        // });

        // this.scheduleOnce(() => {
        //     GPool.destroyPool("LabelIten");
        // }, 5);

        // this.scheduleOnce(() => {
        //     GPool.destroyAllPool();
        // }, 30);

    }

}